 {include file="public/header" /}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">图纸管理</a>
        <a>
          <cite>内部图纸</cite>
        </a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>

        <!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
        <button class="layui-btn" onclick="x_admin_show('添加内图','{:url(\'index/Internal/internalAdd\')}',400,400)"><i class="layui-icon"></i>添加</button>
        <div class="layui-input-inline">
            <!--<input type="tel" id="findText" lay-verify="required|phone" autocomplete="off" placeholder="请输入关键字..." class="layui-input">-->
            <form class="layui-form" action="{:url('index/Internal/internalInfo')}" method="post">
                {if $mode == 1}
                <input type="hidden" name="model" value="1" >
                <input type="hidden" name="order" value="{$order}" >
                {/if}
                <div class="layui-input-inline">
                    <input type="text" name="modules" autocomplete="off" placeholder="请输入关键字..." class="layui-input">
                </div>
                <div class="layui-input-inline">
                    <select name="id" lay-search="" >
                        <option value=""></option>
                        <optgroup label="内图编号">
                            {volist name="$internalCode" id="InfoList"}
                            <option value="{$InfoList.id}">{$InfoList.drawing_Internal_id}</option>
                            {/volist}
                        </optgroup>
                    </select>
                </div>
                <button type="submit" class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </form>
        </div>
        {if $mode == 1}
        <button class="layui-btn" onclick="exeOrder()"><i class="layui-icon"></i>生成订单明细</button>
        {/if}
        <span class="x-right" style="line-height:40px">共{$countInternalInfo}条 · 共{$countInternalInfo/25|getInt}页</span>
        <script>
            // $(function () {
            //     $("input").click(function () {
            //         $("input").val("");
            //     });
            //     $("xblock").click(function () {
            //         $("dd").val("");
            //     });
            // });
        </script>
    </xblock>
    <div class="container-wrap">
        <div class="box-1">
            <table class="layui-table">
                <thead>
            <tr>
                {if $mode == 1}
                <th width="20px;">
                    <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
                </th>
                {/if}
                <th width="2%">
                    操作
                    {if $mode == 1}
                    &nbsp;
                    {if $code == 'M'}
                    <a href="{:url('/index/Internal/internalInfo',['model'=>1,'order'=>$order])}"> <span  style="color: red">组</span></a>
                    {elseif $code == 'N'/}
                    {else/}
                    <a href="{:url('/index/Internal/internalInfo',['code'=>'M','model'=>1,'order'=>$order])}" style="color:#3020d2;"> <span >组</span></a>
                    {/if}

                    {else}
                    &nbsp;
                    {if $code == 'M'}
                    <a href="{:url('/index/Internal/internalInfo')}"> <span  style="color: red">组</span></a>
                    {elseif $code == 'N'/}
                    {else/}
                    <a href="{:url('/index/Internal/internalInfo',['code'=>'M'])}" style="color:#3020d2;"> <span >组</span></a>
                    {/if}
                    {/if}
                </th>
                <th width="13%">
                    内图编号
                    <span class="layui-table-sort layui-inline"  lay-sort="{if $sort == 'asc'}asc{else}desc{/if}">
                <a href="{:url('/index/Internal/internalInfo',['sort'=>'asc'])}"><i class="layui-edge layui-table-sort-asc"></i></a>
                <a href="{:url('/index/Internal/internalInfo',['sort'=>'desc'])}"><i class="layui-edge layui-table-sort-desc"></i></a>
              </span>
                </th>
                <th>所属组件图纸</th>
                <th>备注</th>
                <th>创建人</th>
                <th>创建时间</th>
                <th>修改人</th>
                <th>修改时间</th>

            </tr>
        </thead>
        <tbody>
        {volist name="internalInfo" id="info"}
        <tr>
            {if $mode == 1}
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$info.drawing_Internal_id}'><i class="layui-icon">&#xe605;</i></div>
            </td>
            {/if}

            <td class="td-manage" width="50px;">
                <a title="编辑"onclick="x_admin_show('修改操作','{:url(\'index/Internal/edit\',[\'id\'=>$info.id])}',500,400)" href="javascript:;">
                    <i style="color: green" class="layui-icon"></i>
                </a>
                <a title="删除" onclick="delete_(this,'{$info.id}')" href="javascript:;">
                    <i  style="color:red;" class="layui-icon"></i>
                </a>
                <a title="添加明细" onclick="x_admin_show('为内图 <span class=\'layui-badge layui-bg-blue\'>{$info.drawing_Internal_id}</span> 添加明细','{:url(\'index/Internal/addDetial\', [\'id\'=>$info.drawing_Internal_id])}')" href="javascript:;"><i style="color: green" class="iconfont nav_right">&#xe6b9;</i></a>
            </td>
            <td>
                <?php
                    $count = getCodet($info['drawing_Internal_id']);
                ?>
                {if $count == 0}
          {$info.drawing_Internal_id}
                {else}
                <a title="序号{$info.drawing_Internal_id}" onclick="x_admin_show('<span class=\'layui-badge layui-bg-blue\'>{$info.drawing_Internal_id}</span> 的所有明细','{:url(\'index/Blueprint/blueprintInfo\', [\'modules\' => $info.drawing_Internal_id])}')" href="javascript:;"> <span style="color: #1E9FFF">{$info.drawing_Internal_id}</span></a>
                {/if}
            </td>
            <td>
                <?php
                    if($info['assembly_code'] != null){
                        echo $info['assembly_code'];
                    }else{
                        echo "";
                    }
                ?>
            </td>
            <td>{$info.remark}</td>
            <td>{$info.create_name}</td>
            <td>{$info.create_time}</td>
            <td>{$info.modify_name}</td>
            <td>{$info.update_time}</td>

        </tr>
        {/volist}
        </tbody>
    </table>
        </div>
    </div>
    <div class="page">
        {$internalInfo|raw}
    </div>

</div>
<script>
    function exeOrder() {
        var data = tableCheck.getData();
        var code = "{$order}";
        var index = parent.layer.getFrameIndex(window.name);
        if(data == ''){
            layer.msg('请选择数据');
            return;
        }
        //关闭当前弹出层
        x_admin_show('填写订单明细',"{:url('index/Order/addOrderDetail')}?id="+data+"&order="+code+"&type=n");

    }
    /*删除*/

    function delete_(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            var url = "{:url('/index/Internal/delete')}";
            var postData ={"id":id};
            $.post(url,postData,function (result) {
                if(result === 1 ){
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!',{icon:1,time:1000});
                }else {
                    layer.alert("删除失败", {icon: 5});
                }
            },"json");
        });
    }
    //批量删除
    function delAll (drawing_detail_id) {
        var data = tableCheck.getData();
        if(data == ''){
            layer.msg('请选择需要删除的数据');
            return;
        }
        layer.confirm('确认要删除吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            $.ajax({
                url:"{:url('/index/Internal/delAll')}",
                type:"POST",
                dataType:"json",
                data:{
                    dra_id:drawing_detail_id,
                    data:data   //数据
                },
                success:function (res) {
                    if(res === 1 ){
                        layer.alert("删除成功", {icon: 6},function () {
                            window.location.reload();  //刷新父级页面
                        });
                    }else {
                        layer.alert("删除失败", {icon: 5});
                    }
                },
            });
        });
    }
</script>
</body>
</html>